<template>
	<view >
		<myHead :title="title" />
		<uni-forms ref="form" >
		 	<uni-forms-item label="预览" name="" lable-position="left" >
		 		<!-- 显示关闭按钮 -->
		 		<uni-notice-bar 
		 		 showIcon="true"
		 		  :text="content"></uni-notice-bar>
		 	</uni-forms-item>
		 	<uni-forms-item label="编辑" name="" lable-position="left" >
		 		<uni-easyinput type="textarea" v-model="content"></uni-easyinput>
		 	</uni-forms-item>
		 </uni-forms>
		 
		 	<button type="default" @click="subimt" >提交</button>
		  
		
	</view>
</template>

<script>
	import {upNotice} from '@/api/api_notice.js'
	import myHeader from '../components/head.vue'
	export default {
		data(){
			return {
				title:"公告编辑",
				content:"",
			}
		},components:{
				myHead:myHeader,
			},
		methods: {
		 subimt(){
			 if(this.content.length<=0){
				 uni.showToast({
				 	title:"请输入公告",
					duration:1000,
					icon:"none"
				 })
				 return
			 }
			 let _this = this 
			 uni.showModal({
			 	title: '提示',
			 	content: '是否提交',
			 	success: res => {
					if(res.confirm){
						 upNotice(
							[{noticeContent:_this.content}]
						 ).then(res=>{
							 uni.navigateBack()
						 })
					}
				},
			 	fail: () => {},
			 	complete: () => {}
			 });
		 },
		},
	}
</script>
<style lang="scss" scoped>	
</style>